package com.jffccloud.provider.web;

import com.jffccloud.common.web.wrapper.WrapMapper;
import com.jffccloud.common.web.wrapper.Wrapper;
import com.jffccloud.provider.api.model.OrderDto;
import com.jffccloud.provider.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/user")
@Api(value = "Web-UserController", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Slf4j
public class UserController{
    @Resource
    private IUserService userService;
    @PostMapping(value = "/getOrder/{orderNo}")
    @ApiOperation(httpMethod = "POST", value = "获取订单信息")
    public Wrapper<OrderDto> getOrder(@PathVariable String orderNo) {
        try {
            OrderDto o = userService.queryOrderByNo(orderNo);
            return WrapMapper.ok(o);
        }catch(Exception e){
            log.error("获取订单出错,"+e.getMessage(),e);
            return WrapMapper.error(e.getMessage());
        }
    }

}
